﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MyMvcStoreApplication.Models;
using System.Data.Entity;

namespace MyMvcStoreApplication.Common
{
    public class MusicStoreInitializer : DropCreateDatabaseIfModelChanges<MusicStoreEntities>
    {
        protected override void Seed(MusicStoreEntities context)
        {
            base.Seed(context);
            
            //generos
            var generoPop = context.Generos.Add(new Genero
            {
                ID = 1,
                Nombre = "Pop"
            });
            var generoDance = context.Generos.Add(new Genero
            {
                ID = 2,
                Nombre = "Dance",
            });
            var generoRock = context.Generos.Add(new Genero
            {
                ID = 3,
                Nombre = "Rock",
            });
            context.Generos.Add(new Genero
            {
                ID = 4,
                Nombre = "Jazz",
            });
            context.Generos.Add(new Genero
            {
                ID = 5,
                Nombre = "Clásico",
            });

            //artistas
            context.Artistas.Add(new Artista
            {
                ID = 1,
                Nombre = "Armin Van Buuren",
                Albumes = new List<Album> { new Album { ID = 1, Nombre = "Mirage", Genero = generoDance, TapaAlbumURL = "http://ecx.images-amazon.com/images/I/51GO876GsdL._SL500_AA300_.jpg" } }
            });
            context.Artistas.Add(new Artista
            {
                ID = 2,
                Nombre = "Madonna",
                Albumes = new List<Album> 
                { 
                    new Album { ID = 2, Nombre = "Confesions on a dance floor", Genero = generoPop, Likes = 2 , TapaAlbumURL = "http://ecx.images-amazon.com/images/I/51brGkLgB0L._SL500_AA280_.jpg" },
                    new Album{ ID = 3, Nombre = "Hard candy", Genero = generoPop, Likes = 4, TapaAlbumURL = "https://www.auralexploits.com/ebay_images/lp/Madonna_HardCandy_1.jpg"}
                }
            });
            context.Artistas.Add(new Artista
            {
                ID = 3,
                Nombre = "Lady Gaga",
                Albumes = new List<Album> { new Album { ID = 4, Nombre = "Born this way", Genero = generoPop, TapaAlbumURL = "http://cdn.buzznet.com/media-cdn/jj1/headlines/2011/02/lady-gaga-born-this-way-single-art.jpg" } }
            });
            context.Artistas.Add(new Artista
            {
                ID = 4,
                Nombre = "The ting tings",
                Albumes = new List<Album> { new Album { ID = 5, Nombre = "Hands", Genero = generoDance } }
            });
            context.Artistas.Add(new Artista
            {
                ID = 5,
                Nombre = "Starsailor",
                Albumes = new List<Album> { new Album { ID = 6, Nombre = "On the outside", Genero = generoRock } }
            });
            context.SaveChanges();
        }
    }
}